﻿using System;
using System.ComponentModel;
using RaytracerLib.MathLib;
using RaytracerLib.Attenuations;
using RaytracerLib;
using System.Drawing;

namespace Raytracer.PropertyGridDecorators
{
    public abstract class AttenuationProperties
    {
    }

    public class ExponentalAttenuationProperties : AttenuationProperties
    {
        public ExponentalAttenuation m_attenuation;

        public ExponentalAttenuationProperties(ExponentalAttenuation a_attenuation)
        {
            m_attenuation = a_attenuation;
        }

        [TypeConverter(typeof(ColorFloatConverter))]
        public ColorFloatProperties Alpha
        {
            get
            {
                return new ColorFloatProperties(
                    () => m_attenuation.Alpha, 
                    (c) => m_attenuation.Alpha = c);
            }
            set
            {
                m_attenuation.Alpha = value.ToColorFloat();
            }
        }
    }

    public class PolynomialAttenuationProperties : AttenuationProperties
    {
        public PolynomialAttenuation m_attenuation;

        public PolynomialAttenuationProperties(PolynomialAttenuation a_attenuation)
        {
            m_attenuation = a_attenuation;
        }

        [TypeConverter(typeof(ColorFloatConverter))]
        [Description("Spherical")]
        public ColorFloatProperties A
        {
            get
            {
                return new ColorFloatProperties(
                    () => m_attenuation.A,
                    (c) => m_attenuation.A = c);
            }
            set
            {
                m_attenuation.A = value.ToColorFloat();
            }
        }

        [TypeConverter(typeof(ColorFloatConverter))]
        [Description("Linear")]
        public ColorFloatProperties B
        {
            get
            {
                return new ColorFloatProperties(
                    () => m_attenuation.B,
                    (c) => m_attenuation.B = c);
            }
            set
            {
                m_attenuation.B = value.ToColorFloat();
            }
        }

        [TypeConverter(typeof(ColorFloatConverter))]
        [Description("Constant")]
        public ColorFloatProperties C
        {
            get
            {
                return new ColorFloatProperties(
                    () => m_attenuation.C,
                    (c) => m_attenuation.C = c);
            }
            set
            {
                m_attenuation.C = value.ToColorFloat();
            }
        }
    }
}